<script>
		$(function () {
			$('#supported').text('Supported/allowed: ' + !!screenfull.enabled);

			if (!screenfull.enabled) {
				return false;
			}

			$('#request').click(function () {
				screenfull.request($('#container')[0]);
				// does not require jQuery, can be used like this too:
				// screenfull.request(document.getElementById('container'));
			});

			$('#exit').click(function () {
				screenfull.exit();
			});

			$('#toggle').click(function () {
				screenfull.toggle($('#container')[0]);
			});

			$('#request2').click(function () {
				screenfull.request();
			});

			$('#demo-img').click(function () {
				screenfull.toggle(this);
			});

			$('#demo-video').click(function () {
				screenfull.toggle(this);
			});

			// a little hack to be able to switch pages while in fullscreen.
			// we basically just creates a seamless iframe and navigate in that instead.
			$('#iframe').click(function () {
				// We create an iframe and fill the window with it
				var iframe = document.createElement('iframe')
				iframe.setAttribute('id', 'external-iframe');
				iframe.setAttribute('src', 'http://bbc.com');
				iframe.setAttribute('frameborder', 'no');
				iframe.style.position = 'absolute';
				iframe.style.top = '0';
				iframe.style.right = '0';
				iframe.style.bottom = '0';
				iframe.style.left = '0';
				iframe.style.width = '100%';
				iframe.style.height = '100%';
				$('#container').prepend(iframe);
				document.body.style.overflow = 'hidden';
			})

			document.addEventListener(screenfull.raw.fullscreenchange, function () {
				var elem = screenfull.element;

				$('#status').text('Is fullscreen: ' + screenfull.isFullscreen);

				if (elem) {
					$('#element').text('Element: ' + elem.localName + (elem.id ? '#' + elem.id : ''));
				}

				if (!screenfull.isFullscreen) {
					$('#external-iframe').remove();
					document.body.style.overflow = 'auto';
				}
			});

			$(document).on(screenfull.raw.fullscreenchange, function () {
				console.log('Fullscreen change');
			});

			// trigger the onchange() to set the initial values
			screenfull.onchange();
		});
		</script>